<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="format-detection" content="telephone=no">
    <meta name="description" content="">
    <meta http-equiv="x-dns-prefetch-control" content="on">

    <title>订单详情</title>
    <link href="../../css/css.css" rel="stylesheet" type="text/css">
    <script src="../../js/jquery-v1.11.2.min.js"></script>
    <script src="../../js/driver.js"></script>
    <script src="../../js/common.js"></script>

    <link rel="stylesheet" href="http://cache.amap.com/lbs/static/main1119.css"/>
    <script type="text/javascript" src="http://webapi.amap.com/maps?v=1.3&key=2f1e32d7ca4e228e28117c94dc51cc6d"></script>
    <script type="text/javascript" src="http://cache.amap.com/lbs/static/addToolbar.js"></script>
        
</head>
<body>
<section class="tabbtnarea" style="z-index: 999">
    <li class="w33 rline" id="goOrder1">订单信息</li>
    <li class="w33 rline"><span class="tabfouse">订单轨迹</span></li>
    <li class="w33" id="goOrder3">费用明细</li>
</section>
<section class="mt44">
    <div id="container"></div>
    <div id="panel"></div>
    <div class="button-group">
        <input type="button" class="button" value="开始动画" id="start"/>
        <input type="button" class="button" value="停止动画" id="stop"/>
    </div>
</section>

<section class="viewdriverinfo">
    <div class="itemgroup">
        <div class="userphoto ml15"><img src="../../img/user_photo.png" width="100%" height="100%" class="userimg"/></div>
        <div class="photoitem lh24">
            <span class="itemname">
                <span id="driverName">暂无司机</span>
                <i class="iconfont font12 mr5 yellow">&#xe640;</i><font class="font12 gray mr5"><span id="score"></span></font>
                <font class="gray font12"><span id="orderCount">0单</span></font>
            </span>
            <span class="itemprofession" id="vechileNum">沪A12345</span>
            <span class="itemsubname">
            &nbsp;
            <!--     黑色 依维柯 -->
            </span>
        </div>
        <div class="tel_message" id="telDive">
          
          
        </div>
        
    </div>
</section>
<script type="text/javascript">
/* $(function (){
	 //token验证
		checkToken();
	});  */
    $(document).ready(function () {
        var waybillId = GetArgsFromHref("waybillId");
      //'customerUuid':customerUuid
    	var customerUuid=getCookie("customerUuid")
        var url = _global.serverHost + "/consignerOrderManger/orderTrack.htm";
        var data = {'waybillId': waybillId,'customerUuid':customerUuid};
        _callAjaxRequest(url, data, ajaxBack);

        function ajaxBack(data) {
            $("#goOrder1").attr("onclick", "goOrder1('" + data.waybill.id + "')");
            $("#goOrder3").attr("onclick", "goOrder3('" + data.waybill.id + "')");
            var waybill = data.waybill;
            var  consignDriver=data.consignDriver;
            var  consignDriverAssessSum=data.consignDriverAssessSum;
            $("#vechileNum").html(waybill.vehicleNum);
            if(consignDriverAssessSum!=undefined && consignDriverAssessSum !=null){
            	 var score = consignDriverAssessSum.score;
                 $("#score").html(score);
            }
           
            if(consignDriver!=undefined && consignDriver !=null ){
            	
            	$("#orderCount").html(consignDriver.driverOrderCount+"单");
            	$("#driverName").html(data.driverName);
            }
            
            if(waybill.driverMobile != undefined && waybill.driverMobile !=null){
            	
            	
            	var telDive= '<a href="tel:'+waybill.driverMobile+'">'+'<div class="telbtn mr10"><i class="icon iconfont">&#xe71e;</i></div>'
                +'</a> ';
                
            	$("#telDive").html(telDive);
            }
           
			var wayBillStatus=	waybill.status*1;
            var lon = data.waybill.startLon;
            var lat = data.waybill.startLat;
            var driverLon = data.driverLon;
            var driverLat = data.driverLat;
            var startLon= data.waybill.startLon;
            var startLat = data.waybill.startLat;
            var endLon = data.waybill.endLon;
            var endLat = data.waybill.endLat;
            if (data.waybillTraceList != null && data.waybillTraceList.length > 0 && data.waybillTraceList[0] != null) {
                lon = data.waybillTraceList[0].lon;
                lat = data.waybillTraceList[0].lat;
            }
            var marker, lineArr = [];
            var map, route;
            //基本地图加载
            map = new AMap.Map("container", {
                resizeEnable: true
            });
            //绘制初始路径
            var path = [];
            path.push([startLon, startLat]);
            
			if(driverLon==undefined || driverLon==null || driverLon==''){
				 
   			}else{
   				var orderFee=data.orderFee;
   				
   				if(orderFee!=undefined && orderFee !=null && orderFee!=''){
   					
   				}else{
   					orderFee='';
   				}
   				
   			//订单开始才会显示终点位置
		           if(wayBillStatus>=50){
		        	   path.push([driverLon, driverLat]); 
		           }
	   			 marker = new AMap.Marker({
	                 map: map,
	                 position: [driverLon, driverLat],
	                 icon: "http://webapi.amap.com/images/car.png",
	                 offset: new AMap.Pixel(-26, -13),
	                 autoRotation: true
	             });
	   			 if(wayBillStatus>=50){
	   				 marker.content = "距离"+data.driverDesc+"："+data.distance+"km <br/> 预计行驶："+data.duration+"分<br/>当前费用："+orderFee +"元</div>";
	   			 }else{
	   				 marker.content = "距离"+data.driverDesc+"："+data.distance+"km <br/> 预计行驶："+data.duration+"分</div>";
	   			 }
	            
	             var infoWindow = new AMap.InfoWindow({offset: new AMap.Pixel(0, -30)});
	             marker.on('click', function(e){
	 	        	 infoWindow.setContent(e.target.content);
	 	        	    infoWindow.open(map, e.target.getPosition());
	 	        });
	 	        marker.emit('click', {target: marker});
	            
	             map.setFitView();
	             //path.push([driverLon, driverLat]); 
   			}
           /*  */
           
           //订单开始才会显示终点位置
           if(wayBillStatus>=50){
        	   path.push([endLon, endLat]); 
           }
            
            map.plugin("AMap.DragRoute", function() {
                route = new AMap.DragRoute(map, path, AMap.DrivingPolicy.LEAST_FEE); //构造拖拽导航类
                route.search(); //查询导航路径并开启拖拽导航
            });
          

            
            
           
        }
    });
    function goOrder1(waybillId) {
    	 window.location.href="../../customer/order/order_detail.html?waybillId="+waybillId;
    }

    function goOrder3(waybillId) {
    	window.location.href= "../../customer/order/price_detail.html?waybillId="+waybillId;
    }
    
  /*   function myrefresh() 
    { 
    window.location.reload(); 
    } 
    setTimeout('myrefresh()',10000); //指定1秒刷新一次  */
</script>
</body>
</html>